//
//  PGStatus.swift
//  PGWeibo
//
//  Created by Apple on 15/11/9.
//  Copyright © 2015年 Apple. All rights reserved.
//

import UIKit

class PGStatus: NSObject {
    /// 微博ID
    var id: Int = 0
    /// 微博信息内容
    var text: String?
    /// 微博创建时间
    var created_at: String?
    /// 微博来源
    var source: String?
    /// 缩略图配图数组 key: thumbnail_pic
    var pic_urls: [[String: String]]?
    /// 用户模型
    var user: PGUser?
    /// 转发的微博
    var retweeted_status: PGStatus?
    
    
    init(dict: [String: AnyObject]) {
        super.init()
        setValuesForKeysWithDictionary(dict)
    }
    override func setValue(value: AnyObject?, forUndefinedKey key: String) { }
    /// kvc 会调用此方法
    override func setValue(value: AnyObject?, forKey key: String) {
        if key == "user" {
            if let dict = value as? [String: AnyObject] {
                user = PGUser(dict: dict)
            }
            return
        }
        if key == "retweeted_status" {
            if let dict = value as? [String: AnyObject] {
                retweeted_status = PGStatus(dict: dict)
            }
            return
        }
        super.setValue(value, forKey: key)
    }
    
    
    override var description: String {
        let keys = ["id", "text", "created_at", "source", "user", "retweeted_status"]
        
        return dictionaryWithValuesForKeys(keys).description
    }
}

